﻿using System;
using System.Diagnostics;

namespace Map_Creator.RedoUndo.Actions
{
    class ArrayReplaceAction : IAction
    {
        private Array array;
        private int[] indexes;
        private object newItem;
        private object prevItem;

        public ArrayReplaceAction(Array array, int[] indexes, object newItem)
        {
            this.array = array;
            this.indexes = indexes;
            this.newItem = newItem;

            prevItem = array.GetValue(indexes);
        }

        public void Do()
        {
            array.SetValue(newItem,indexes);
        }

        public void Undo()
        {
            array.SetValue(prevItem, indexes);
        }

        public string GetDescription()
        {
            return "Replace Array With" + newItem;
        }

        public string GetName()
        {
            return "Array Replace";
        }
    }
}
